# 类
# 类的定义
# 类的方法
# 类的实例
# 类的继承
# 类的导入

from car import Car

class Dog():
    """Dog"""

    def __init__(self: dict, name: str, age:int) -> None:
        """
        初始化方式 __init__ 是特殊的方式，实例化时会自动运行，
        self 形参必不可少且必须在第一位，其他形参可自由传递
        """
        # print(type(self))
        self.name = name
        self.age = age

    def sit(self):
        """模拟小狗蹲下"""
        print(self.name.title() + 'is now sitting.')

    def roll_over(self):
        """模拟小狗打滚"""
        print(self.name.title() + 'rolled over!')


my_dog = Dog('willie', 6)

print("my dog's name is " + my_dog.name.title() + '.')
print("my dog is " + str(my_dog.age) + ' years old.')

my_dog.sit()
my_dog.roll_over()

your_dog = Dog('lucy', 1)

your_dog.sit()

class Restaurant():
    """餐馆"""

    def __init__(self, restaurant_name, cuisine_type) -> None:
        """初始化"""
        self.restaurant_name  = restaurant_name
        self.cuisine_type = cuisine_type

    def describe_restaurant(self):
        print(self.restaurant_name)
        print(self.cuisine_type)

    def open_restaurant(self):
        print(self.restaurant_name + 'is opening.')



restaurant_1 = Restaurant('猪脚饭', 'ff')

restaurant_1.describe_restaurant()
restaurant_1.open_restaurant()

my_new_car = Car('audi', 'a4', 2016)

print(my_new_car.get_descriptive_name())
my_new_car.read_odometer()
my_new_car.update_odometer(200)
my_new_car.read_odometer()

# 继承
class ElectricCar(Car):

    def __init__(self: dict, make: str, model: str, year: int) -> None:
        super().__init__(make, model, year)
        self.battery_size = 70

    def describe_battery(self):
        print("This car has a " + str(self.battery_size) + "-kwh battery.")

    def fill_gas_tank(self):
        """重写父类方法"""
        print("This car doesn't need a gas tank!")


my_tesla = ElectricCar('tesla', 'model s', 2016)

print(my_tesla.get_descriptive_name())
my_tesla.describe_battery()
my_tesla.fill_gas_tank()

